/*
 *  $Id: FontInfo.cs 1216 2010-11-26 17:35:07Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.BitmapFont;
using AgateLib.DisplayLib;
using AgateLib.Geometry;

using Nereal.Serialization;

namespace Ragima.Languages {
    /// <summary>
    /// Информация о шрифте.
    /// </summary>
    public sealed class FontInfo {
        /// <summary>
        /// Значение DPI для пересчета из пикселей в пункты.
        /// TODO: получение текущего DPI в системе.
        /// </summary>
        private const float DPI = 96;

        private BitmapFontOptions _info;

        public FontInfo() {
            _info = new BitmapFontOptions();
        }

        [XmlName("family")]
        public string FontFamily {
            get { return _info.FontFamily; }
            set { _info.FontFamily = value; }
        }

        [XmlName("size")]
        public int Size {
            get { return (int) (_info.SizeInPoints * DPI / 72); }
            set { _info.SizeInPoints = (float) value * 72 / DPI; }
        }

        [XmlName("style"), DefaultValue(FontStyle.None)]
        public FontStyle FontStyle {
            get { return _info.FontStyle; }
            set { _info.FontStyle = value; }
        }

        [XmlName("border"), DefaultValue(false)]
        public bool CreateBorder {
            get { return _info.CreateBorder; }
            set {
                _info.CreateBorder = value;
                if (!value)
                    _info.BorderColor = Color.Black;
            }
        }

        [XmlName("borderColor"), DefaultValue("000000")]
        public Color BorderColor {
            get { return _info.BorderColor; }
            set { _info.BorderColor = value; }
        }

        [XmlName("edges"), DefaultValue(BitmapFontEdgeOptions.IntensityAlphaColor)]
        public BitmapFontEdgeOptions EdgeOptions {
            get { return _info.EdgeOptions; }
            set { _info.EdgeOptions = value; }
        }

        public BitmapFontOptions GetOptions() {
            BitmapFontOptions options = new BitmapFontOptions(_info.FontFamily, _info.SizeInPoints, _info.FontStyle);
            options.CreateBorder = _info.CreateBorder;
            options.BorderColor = _info.BorderColor;
            options.EdgeOptions = _info.EdgeOptions;
            return options;
        }
    }
}
